<template>
  <div class="el-dialog-div" ref="formBox">
    <el-form ref="form" :model="params" label-width="120px" :rules="rules">
      <el-form-item label="GP" prop="userId">
        <el-select v-model="queryParams.search" filterable placeholder="输入GP,名字,电话号码" :filter-method="query" style="width:100%" @change="selectUser">
          <el-option v-for="item in userList" :key="item.value" :label="item.label" :value="item">
          </el-option>
        </el-select>
      </el-form-item>

      <el-form-item label="金积分数额" prop="amount">
        <el-input-number v-model="params.amount" />
      </el-form-item>

      <el-form-item label="说明" prop="remark">
        <el-input class="form-input" v-model="params.remark" />
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
import { screenUser } from "@/api/system/user";
import { vipLevelGiveEnum } from '@/common/enums'
export default {
  name: 'FormView',
  props: {
    form: {
      type: Object,
    },
  },

  data() {
    return {
      vipLevelGiveEnum,
      search: '',

      params: {
        userId: undefined,
        amount: undefined,
        remark: undefined
      },
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        search: undefined
      },
      vipEndTime: '',
      userList: [],
      rules: {
        userId: [{ required: true, message: "必填", trigger: "blur" }],
        amount: [{ required: true, message: "必填", trigger: "blur" }],
        remark: [{ required: true, message: "必填", trigger: "blur" }],
      }
    }
  },

  computed: {


  },

  mounted() {
    this.reset();
    this.getScreenUserList();
  },

  methods: {
    selectUser(a) {

    },
    query(params) {
      this.queryParams.search = params
      this.getScreenUserList();
    },

    reset() {
      this.params.userId = undefined;
      this.queryParams.search = undefined;
      this.params = {};
      this.queryParams.pageNum = 1;
    },

    getScreenUserList() {
      screenUser(this.queryParams).then((response) => {
        if (response.code == 200) {
          this.userList = response.data;
          this.userList.forEach(res => {
            res.label = res.id + '--' + res.phone + '--' + res.nickname;
            res.value = res.id;
          })
        }
      });
    },
  }
}
</script>

<style lang="scss" scoped>
.el-dialog-div {
  height: 70vh;
  overflow: auto;
  padding-right: 30px;
}
.table-box {
  margin-left: 40px;
}
</style>